Merge pull request #452 from PetroFeed/markdown_scenario_description

Support for markdown on scenario description.

Andrew Cantino 10 年之前
父节点
当前提交
25f4d748fc

+ 0 - 1
Gemfile

@@ -123,4 +123,3 @@ else
123 123
   gem 'unicorn', platform: :ruby_18
124 124
   gem 'rails_12factor', platform: :ruby_18
125 125
 end
126
-

+ 7 - 0
app/helpers/markdown_helper.rb

@@ -0,0 +1,7 @@
1
+module MarkdownHelper
2
+
3
+  def markdown(text)
4
+    Kramdown::Document.new(text, :auto_ids => false).to_html.html_safe
5
+  end
6
+
7
+end

+ 1 - 1
app/views/scenario_imports/_step_two.html.erb

@@ -30,7 +30,7 @@
30 30
     </div>
31 31
 
32 32
     <% if @scenario_import.parsed_data["description"].present? %>
33
-      <blockquote><%= @scenario_import.parsed_data["description"] %></blockquote>
33
+      <blockquote><%= markdown(@scenario_import.parsed_data["description"]) %></blockquote>
34 34
     <% end %>
35 35
 
36 36
   </div>

+ 1 - 1
app/views/scenarios/show.html.erb

@@ -6,7 +6,7 @@
6 6
       </div>
7 7
 
8 8
       <% if @scenario.description.present? %>
9
-        <blockquote><%= @scenario.description %></blockquote>
9
+        <blockquote><%= markdown(@scenario.description) %></blockquote>
10 10
       <% end %>
11 11
 
12 12
       <%= render 'agents/table', :returnTo => scenario_path(@scenario) %>

+ 14 - 0
spec/helpers/markdown_helper_spec.rb

@@ -0,0 +1,14 @@
1
+require 'spec_helper'
2
+
3
+describe MarkdownHelper do
4
+
5
+  describe '#markdown' do
6
+
7
+    it 'renders HTML from a markdown text' do
8
+      markdown('# Header').should =~ /<h1>Header<\/h1>/
9
+      markdown('## Header 2').should =~ /<h2>Header 2<\/h2>/
10
+    end
11
+
12
+  end
13
+
14
+end